<template>
    <div id="sign-in-query-container">
        <div class="sign-in-query-dept-box">
            <Select v-model="exp" class="sign-in-query-select">
                <Option v-for="item in monthList" :value="item.exp" :key="item.exp">
                    {{ item.context }}
                </Option>
            </Select>
            <Input 
                class="sign-in-query-sid" 
                v-model="sid" 
                placeholder="学号/姓名"/>
            <Button 
                type="primary" 
                icon="ios-search" 
                class="sign-in-query-search"
                @click="getUnsignList()">
                查询
            </Button>
            <Divider orientation="left">筛选器</Divider>
            <Query_Selector/>
            <Divider orientation="left">结果</Divider>
            <Query_View v-if="resultList.length != 0" :resultList="resultList"/>
        </div>
    </div>
</template>

<script>

import local_script from "@sign/js/util";
import local_vuex from "@sign/js/vuex";
import unsign_request from "@/axios/unsign";
import Query_Selector from "@sign/vue/query-selector";
import Query_View from "@sign/vue/query-view";

export default {
    data() {
        return {
            // 学号
            sid: "",
            // 日期表达式
            exp: "",
            // 月份列表
            monthList: [],
            // 查询结果列表
            resultList: []
        }
    },
    mounted() {
        // 获取月份列表
        this.monthList = local_script.getMonthList();
        // 初始化月份表达式
        this.exp = this.monthList[0].exp;
        // 默认调用一次
        this.getUnsignList();
    },
    methods: {
        async getUnsignList() {
            this.resultList = await unsign_request.axiosGetRecord(
                this.sid, this.exp, 
                local_vuex.state.dept, 
                local_vuex.state.group
            );
            local_vuex.state.resultList = this.resultList;
        }
    },
    components: {
        Query_Selector,
        Query_View
    }
}
</script>

<style lang="scss">
@import "@sign/scss/query-index.scss";
</style>